@extends("admin.layout.main")

@section("content")

    <style>
        table thead tr th {
            text-align: center
        }

        table tbody tr td {
            text-align: center
        }
    </style>
    <div class="page-header">
        <h1>
            兑换券列表
        </h1>
    </div>
    <div class="page-header">
        <form action="" style="text-align: right">
            <label style="margin-right: 10px">
                状态：
                <select name="status">
                    <option value="0" @if($where['status']==0) selected @endif>未使用</option>
                    <option value="1" @if($where['status']==1) selected @endif>已使用</option>
                    <option value="2" @if($where['status']==2) selected @endif>已过期</option>
                </select>
            </label>
            <label>
                统计时间：
                <input type="text" id="start_time" name="start_time" value="{{ $where['start_time'] }}">
                至
                <input type="text" id="end_time" name="end_time" value="{{ $where['end_time'] }}">
            </label>
            <button class="btn btn-xs btn-primary">搜索</button>
        </form>
    </div>


    <!-- div.table-responsive -->

    <!-- div.dataTables_borderWrap -->
    <div>
        <table id="" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>兑换券名称</th>
                <th>订单号</th>
                <th>创客ID</th>
                <th>创客昵称</th>
                <th>用户手机号</th>
                <th>抵扣金额</th>
                <th>使用时间</th>
                <th>添加时间</th>
            </tr>
            </thead>

            <tbody>
            @foreach($data as $v)
            <tr>
                <td>创客产品兑换券</td>
                <td>{{ $v->order['order_sn'] }}</td>
                <td>{{ $v->user['id'] }}</td>
                <td>{{ $v->user['name'] }}</td>
                <td>{{ $v->user['mobile'] }}</td>
                <td>{{ $v->amount }}</td>
                <td>{{ $v->use_time }}</td>
                <td>{{ $v->created_at }}</td>
            </tr>
            @endforeach
            </tbody>
        </table>
        <div class="pagination pagination-centered">
            {{ $data->appends($where)->links('admin.layout.page') }}
        </div>
    </div>
    <link rel="stylesheet" href="/plugins/jedate/jedate.css"/>
    <script src="/plugins/jedate/jedate.min.js"></script>
    <script>
        var start = {
            dateCell: "#start_time",
            format: "YYYY-MM-DD",
            isinitVal: false,
            isTime: false, //isClear:false,
            maxDate: "{{ $where['end_time'] }}",
            minDate: "",
            choosefun: function (datas) {
                end.minDate = datas;
                $("input[name='begin']").val(datas);
            }
        };
        jeDate(start);
        var end = {
            dateCell: "#end_time",
            format: "YYYY-MM-DD",
            isinitVal: false,
            isTime: false, //isClear:false,
            maxDate: "2099-01-01 23:59:59",
            minDate: "{{ $where['start_time'] }}",
            choosefun: function (datas) {
                start.maxDate = datas;
                $("input[name='end']").val(datas);
            }
        };
        jeDate(end);
    </script>
@endsection